<template>
  <div class="topic wrapper">
    <div class="title">
      <div class="left">
        <h3>最新专题</h3>
      </div>
      <div class="right">
        <a href="#" class="more">
          查看全部<span class="iconfont icon-arrow-right-bold"></span>
        </a>
      </div>
    </div>
    <div class="topic_bd">
      <ul style="margin-left: 18px;">
        <transition-group name="fade" tag="ul">
        <li v-for="(item, index) in topics" :key="index" class="fade-item">
     <!-- <li v-for="(item, index) in topics" :key="index" class="topic-item"> -->
          <a href="#">
            <div class="pic">
              <img :src="item.imgSrc" alt="" />
              <div class="info">
                <div class="left">
                  <h5>{{ item.title }}</h5>
                  <p>{{ item.description }}</p>
                </div>
                <div class="right"><span>{{ item.tag }}</span></div>
              </div>
            </div>
            <div class="txt">
              <div class="left">
                <p>
                  <span class="iconfont icon-favorites-fill red"></span>
                  <i>{{ item.likes }}</i>
                </p>
                <p>
                  <span class="iconfont icon-browse"></span>
                  <i>{{ item.views }}</i>
                </p>
              </div>
              <div class="right">
                <span class="iconfont icon-comment"></span>
                <i>{{ item.comments }}</i>
              </div>
            </div>
          </a>
        </li>
      </transition-group>
        <!-- <li v-for="(item, index) in topics" :key="index" class="topic-item">
          <a href="#">
            <div class="pic">
              <img :src="item.imgSrc" alt="" />
              <div class="info">
                <div class="left">
                  <h5>{{ item.title }}</h5>
                  <p>{{ item.description }}</p>
                </div>
                <div class="right"><span>{{ item.tag }}</span></div>
              </div>
            </div>
            <div class="txt">
              <div class="left">
                <p>
                  <span class="iconfont icon-favorites-fill red"></span>
                  <i>{{ item.likes }}</i>
                </p>
                <p>
                  <span class="iconfont icon-browse"></span>
                  <i>{{ item.views }}</i>
                </p>
              </div>
              <div class="right">
                <span class="iconfont icon-comment"></span>
                <i>{{ item.comments }}</i>
              </div>
            </div>
          </a> -->
        <!-- </li> -->
      </ul>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      topics: [
        {
          imgSrc: "https://tse4-mm.cn.bing.net/th/id/OIP-C.r-XOzg1AdY1GWmzWC3yYAgHaIt?pid=ImgDet&w=474&h=557&rs=1",
          title: "清平乐中的宋代服饰",
          description: "看《清平乐》赏宋代服饰",
          tag: "《清平乐》",
          likes: 1200,
          views: 1800,
          comments: 246
        },
        {
          imgSrc: "https://tse3-mm.cn.bing.net/th/id/OIP-C._YyumY1EO4vkynfGCdymjQHaEK?pid=ImgDet&w=474&h=266&rs=1",
          title: "宋朝太后的服饰",
          description: "关于太后的服饰",
          tag: "太后服饰",
          likes: 1200,
          views: 1800,
          comments: 246
        },
        {
          imgSrc: "https://img.alicdn.com/bao/uploaded/i3/906495111/O1CN014q2xHc1nct48Tx0iI_!!906495111.jpg",
          title: "宋朝文人的那些服饰",
          description: "关于宋朝文人的服饰",
          tag: "文人服饰",
          likes: 1200,
          views: 1800,
          comments: 246
        }
      ]
    };
  }
};
</script>

<style scoped>
.right .more :hover{
  color: green !important;
}
.topic {
  padding-top: 60px;
  margin-bottom: 40px;
}
.topic_bd ul {
  display: flex;
  justify-content: space-between;
}
.topic_bd li {
  width: 405px;
  height: 355px;
}
.topic_bd .pic {
  position: relative;
  width: 405px;
  height: 288px;
}
.topic_bd .txt {
  display: flex;
  justify-content: space-between;
  padding: 0 15px;
  height: 67px;
  line-height: 67px;
  color: #666;
  font-size: 14px;
}
.topic_bd .txt .left {
  display: flex;
}
.topic_bd .txt .left p {
  margin-right: 20px;
}
.topic_bd .txt .left .red {
  color: #aa2113;
}
.topic_bd .info {
  position: absolute;
  left: 0;
  bottom: 0;
  display: flex;
  justify-content: space-between;
  padding: 0 15px;
  width: 100%;
  height: 90px;
  background-image: linear-gradient(
    180deg,
    rgba(137, 137, 137, 0) 0%,
    rgba(0, 0, 0, 0.9) 100%
  );
}
.topic_bd .info .left {
  padding-top: 20px;
  color: #fff;
}
.topic_bd .info .left h5 {
  margin-bottom: 5px;
  font-size: 20px;
}
.topic_bd .info .right {
  margin-top: 35px;
  padding: 0 7px;
  height: 25px;
  line-height: 25px;
  background-color: #fff;
  color: #aa2113;
  font-size: 15px;
}

.topic_bd .pic img {
  transition: opacity 0.3s ease;
}

.topic_bd .pic:hover img {
  opacity: 0.8;
}

.fade-enter-active, .fade-leave-active {
  transition: opacity 0.5s;
}
.fade-enter, .fade-leave-to /* .fade-leave-active in <2.1.8 */ {
  opacity: 0;
}

.topic_bd .pic img {
    transition: transform 0.3s ease; /* 平滑变换效果 */
  }
  .topic_bd .pic {
    position: relative;
    width: 390px;
    height: 288px;
    overflow: hidden; /* 超出部分隐藏 */
    border-radius: 8px;
  }

  .topic_bd .pic img {
    transition: transform 0.3s ease; /* 平滑变换效果 */
    /* width: 100%; 确保图片宽度填满容器 */
    /* height: auto; 高度自动调整保持宽高比 */
  }

  .topic_bd .pic:hover img {
    transform: scale(1.1); /* 放大到1.1倍 */
  }
</style>